<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-cache,no-store">
    <meta http-equiv="Expires" content="0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <title>用户列表页</title>
    <link rel="stylesheet" th:href="@{/plugins/layui/css/layui.css}" media="all" />
</head>
<body class="layui-container">
<br/>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>个人密码修改</legend>
</fieldset>
<form class="layui-form" method="POST">
    <div class="layui-form-item">
        <label class="layui-form-label">输入旧密码</label>
        <div class="layui-input-inline">
            <input type="password" name="oldPassword" maxlength="50" minlength="6" lay-verify="required" autocomplete="off" placeholder="请输入旧密码" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">输入新密码</label>
        <div class="layui-input-inline">
            <input type="password" name="newPassword" maxlength="50" minlength="6" id="pwd" lay-verify="required" autocomplete="off" placeholder="请输入新密码" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-inline">
            <input type="password" name="newPassword1" maxlength="50" minlength="6" id="regPwd" lay-verify="required|regPwd" autocomplete="off" placeholder="请确认密码" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="save">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script th:src="@{/plugins/layui/layui.js}"></script>
<script>
    layui.config({
        base : '../../build/js/',
        version : '1.0.1'
    }).use([ 'table', 'common' ], function() {
        var $ = layui.$, common = layui.common, form = layui.form;

        form.verify({
            max: function(value, item){ //value：表单的值、item：表单的DOM对象
                var max = $(item).attr("max");
                if (parseInt(value) > parseInt(max)) {
                    return "最大值为" + max;
                }
            },
            min: function(value, item){ //value：表单的值、item：表单的DOM对象
                var max = $(item).attr("min");
                if (parseInt(value) < parseInt(max)) {
                    return "最小值为" + max;
                }
            },
            regPwd: function(value) {
                //获取密码
                var pwd = $("#pwd").val();
                if(!new RegExp(pwd).test(value)) {
                    return '两次输入的密码不一致';
                }
            }
        });

        /**保存*/
        form.on("submit(save)", function(data) {
            var url = "/auth/staff/changePwd.json";

            //异步表单提交
            common.fromPostAjax(url, data.field);
            return false;
        });
    });
</script>
</body>
</html>